/*
	Copyright (C) 2010 2011 Rémi Thebault

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef GANTTAXIS_H
#define GANTTAXIS_H

#include <QGraphicsItem>
#include <QGraphicsScene>

#include "pcchild.h"


class GanttAxis : public QGraphicsItem, public PCChild
{
public:
	GanttAxis(ProCycle* app);
	virtual ~GanttAxis() {
	}

	QRectF boundingRect() const;

	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);


	float unit2px() {
		return m_scale;
	}

	float unit2px (int units) {
		return units * m_scale;
	}

	float px2unit() {
		return 1 / m_scale;
	}

	float px2unit (int pxs) {
		return pxs / m_scale;
	}



	int length () const {
		return m_length;
	}

	void setLength(const int& length) {
		m_length = length;
		m_scale = scene()->width() / m_length;
	}

	double scale() const {
		return m_scale;
	}

	void setScale(const double& scale) {
		m_scale = scale;
		m_length = scene()->width() / m_scale;
	}


private:
	int		m_length;
	double	m_scale;
};


#endif // GANTTAXIS_H
